package com.southpark.framework.control.responders
{
	import com.southpark.framework.control.responders.IResponder;
	
	public class ResponderFactory
	{
		static public function createResponder(onSuccess:Function,onFault:Function=null):IResponder
		{
			return new Responder(onSuccess,onFault);
		}
	}
}


{
	import com.southpark.framework.control.responders.IResponder;
	import com.southpark.framework.control.commands.CommandFault;
	
	
	class Responder implements IResponder
	{
		private var _onSuccess:Function;
		private var _onFault:Function;
		
		public function Responder(onSuccess:Function,onFault:Function)
		{
			_onSuccess = onSuccess;
			_onFault = onFault;
		}
		
		public function onSuccess(result:Object):void
		{
			if (_onSuccess != null) 
			{
				_onSuccess(result);
			};
		}
		
		public function onFault(commandFault:CommandFault):Boolean
		{
			if (_onFault != null) 
			{
				return _onFault(commandFault);
			};
			return false;
		}
	}
	
}